package com.atzzy.ysmall.ysmall_api.ProductCommController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.atzzy.ysmall.ysmall_allService.ProductService.ProService;
import com.atzzy.ysmall.ysmall_allService.ProductService.ProductCommontService;
import com.atzzy.ysmall.ysmall_common.vo.R;
import org.springframework.web.bind.annotation.*;

/**
 * @Author JAVAZeng
 * @Date 2022/3/3 14:19
 * @Version 1.0
 */
@RestController
@RequestMapping("productTui")
@CrossOrigin
public class ProductController {

    @Reference
    private ProService productService;
    @Reference
    private ProductCommontService productCommontService;

    @GetMapping("list-recommends")
    private R listRecommendProdcuts() {
        return productService.listRecommendProdcuts();
    }//这个接口也暂时不用 后期去掉

    @GetMapping("list-good")
    private R listGoodProduct() {
        return productService.lisrGoodProducts();
    }//暂时不用这个接口

    @GetMapping("list-goods")
    private R listGoodProductByImp() {
        return productService.listGoodProductsByImp();
    }

    @GetMapping("list-personal")
    private R listGoodProductPersonal() {
        return productService.listGoodProductPersonal();
    }

    @GetMapping("infodesc")
    private R getProductBasicInfo(Integer productId, String productBusinessName) {
        return productService.getProductBasicInfo(productId, productBusinessName);
    }

    //商品参数
    @GetMapping("get-params")
    private R getProductParamsById(String productId) {
        return productService.getProductParamsById(productId);
    }

    //商品评论
    @GetMapping("get-comments")
    private R getProductCommentsById(String productId) {
        return productService.getProductCommentsById(productId);
    }

    //好评差评中等
    @GetMapping("get-commentsnum")
    private R getProductCommentNum(String productId) {
        return productService.getProductCommentNum(productId);
    }

    //获取商家信息
    @GetMapping("get-buiness")
    private R getBuinessInfo(String buinessName) {
        return productService.getBuinessInfo(buinessName);
    }

    @GetMapping("get-pageComment")
    private R getPageCommnet(String productId, int pageNum, int limit) {
        return productCommontService.getProductCommentsById(productId, pageNum, limit);
    }
    @GetMapping("listbycategoryId")
    private R getProductByCategoryId(@RequestParam("categoryId") int categoryId,int pageNum,int limit){
        return productService.getProductsByCategoryId(categoryId,pageNum,limit);
    }
    @GetMapping("searchProductByKeyword")
    private R searchProductByKeyword(@RequestParam("keyword") String keyword,int pageNum,int limit){
        return productService.searchProduct(keyword,pageNum,limit);
    }
}
